import * as vscode from 'vscode';
import { TagDetector, createCompletionItem } from '../utils';
import { CompletionKinds } from '../constants/completionKinds';
import { CompletionItemConfig } from '../types/completion';


/**
 * Import the zero_opens completion function
 */
export class VueCompletionProvider implements vscode.CompletionItemProvider {
    
    provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {

        // 1. Check if it is within the <script> of the file
        if (!TagDetector.isInsideAnyTag(document, position, ['script'])) {
            return [];
        }

        // 2. Create complement
        const config: CompletionItemConfig = {
            target: 'zero_opens',
            title: '从 "zero_opens" 添加导入',
            subtitle: `import { hello } from 'zero_opens';`,
            insertText: `import { hello } from 'zero_opens';`,
            kind: CompletionKinds.MODULE,
        };
        return [createCompletionItem(config)];
    }
}